package shop.local.gui;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

import shop.local.domain.ShopVerwaltung;

public class LogOutPanel extends JPanel {
	
	protected ShopVerwaltung shop;
	private Eshop eShop = new Eshop();
	private JFrame frame = new JFrame();
	private JButton logOutButton;
	
	public LogOutPanel(JFrame aFrame) {

		try {
			shop = new ShopVerwaltung("Shop");
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		frame = aFrame;
		initialize();

	}

	private void initialize() {

		JLabel logOutLabel = new JLabel ("ausloggen?");
		logOutButton = new JButton();

		logOutButton.setText("raus hier!");
		logOutButton.addActionListener(new RegisterListener());

		setPreferredSize(new Dimension(200, 20));
		this.setLayout(new GridLayout(1,2));
		this.setBackground(new Color(255, 255, 255));

		this.add(logOutLabel);
		this.add(logOutButton);
	}
	class RegisterListener implements ActionListener {
		@Override
		public void actionPerformed(ActionEvent ae) {
			if (ae.getSource().equals(logOutButton)) {
				eShop = new Eshop("SHOP", null);
				frame.dispose();
			}
		}
	}
}
